package
{
	import flash.display.MovieClip;
	import flash.events.Event;
	
	public class MotionListener
	{
		//VARIABLES INTERNAS SETEABLES OBLIGATORIAS.
		
			public var clip:MovieClip;
		
		//VARIABLES INTERNAS SETEABLES OPCIONALES.
			
			
			
		//VARIABLES INTERNAS.
		
			public var aX:Number = 0;
			public var aY:Number = 0;
			public var vX:Number = 0;
			public var vY:Number = 0;	
			private var pvX:Number = 0;
			private var pvY:Number = 0;	
			private var pX:Number = 0;
			private var pY:Number = 0;
		
		//CONSTRUCTOR.
		public function MotionListener()
		{
			
		}
		
		//INIT.
		public function init():void
		{
			//POSICION INICIAL.
			pX = clip.x;
			pY = clip.y;
			
			//INICIA EL ENTERFRAME.
			clip.addEventListener(Event.ENTER_FRAME, enterFrameHandlerMotionListener);
		}
		
		//ENTERFRAME.
		private function enterFrameHandlerMotionListener(evt:Event):void
		{
			//CALCULA LA VELOCIDAD.
			vX = clip.x - pX;
			vY = clip.y - pY;
			
			//CALCULA LA ACELERACION.
			aX = vX - pvX;
			aY = vY - pvY;
			
			//REGISTRA LOS VALORES ACTUALES.
			pvX = vX;
			pvY = vY;
			pX = clip.x;
			pY = clip.y;
			
			//TRACING.
			//trace(aY);
		}
	}
}